package com.cangshi.service;


import com.cangshi.dao.BillMapper;
import com.cangshi.dao.OrderMapper;
import com.cangshi.dao.UserMapper;
import com.cangshi.entity.Bill;
import com.cangshi.entity.Order;
import com.cangshi.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Eoly on 2017/1/16.
 */
@Service("orderService")
public class OrderServiceImpl implements OrderService {

    @Autowired
    OrderMapper orderMapper;

    public List<Order> findByUserId(Integer userId) {
        return orderMapper.selectByUserId(userId);
    }

    public List<Order> findByOrderUserId(Integer orderUserId) {
        return orderMapper.selectByOrderUserId(orderUserId);
    }

    public List<Order> findByGroupId(Integer groupId) {
        return orderMapper.selectByGroupId(groupId);
    }

    public Integer addOrder(Order order) {
        return orderMapper.insertSelective(order);
    }

    public Integer modifyOrder(Order order) {
        return orderMapper.updateByPrimaryKeySelective(order);
    }

    public Order findByOrderId(Integer orderId) {
        return orderMapper.selectByPrimaryKey(orderId);
    }

    public Order findByOrderIdDeeply(Integer orderId) {
        return orderMapper.selectByPrimaryKeyDeeply(orderId);
    }

    public Integer findLastId() {
        return orderMapper.selectLastId();
    }
}
